package com.itfitness.googlemappoi.base

import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import com.itfitness.googlemappoi.bean.BaseBean

open class BaseActivity:AppCompatActivity() {

    /**
     * LiveData监听
     */
    fun <T: BaseBean> addObserve(liveData: LiveData<T>, success:(T) -> Unit, error:(e:Throwable) ->Unit){
        liveData.observe(this){
            if (it.exception == null){
                success(it)
            }else{
                error(it.exception)
            }
        }
    }
}